package multithreading.homework.snck;



import java.util.LinkedList;
import java.util.Random;

public class Demo extends Thread
{
    private int count;
    private LinkedList A;
    public Demo(LinkedList A, String name) {
        super(name);
        this.A =A;
    }
    Random a=new Random();

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    @Override
    public void run() {
        String name=Thread.currentThread().getName();
        while (true) {
            synchronized ("ss") {
                if (A.size() <= 10) {
                    break;
                }
             Object s = A.remove(a.nextInt(A.size()));
                System.out.println(name+"送出了"+s);
                count++;
            }
        }
        System.out.println(getCount());
    }

}
